package BLC

//创建区块链结构体
type Blockchain struct {
	Blocks []*Block //存储有序区块
}

//增加区块到区块链里
func (blc *Blockchain) AddBlockToBlockchain(data string, height int64, preHash []byte) {
	//创建新的区块
	newBlock := NewBlock(data, height, preHash)
	//往链里添加区块
	blc.Blocks = append(blc.Blocks,newBlock)
}

//1.创建带有创世区块的区块链
func CreateBlockchainWithGenesisBlock() *Blockchain {
	//创建创世区块
	genesisBlock := CreateGenesisBlock("Genesis Data.......")
	//返回带有创世区块的区块链对象
	return &Blockchain{[]*Block{genesisBlock}}
}
